#!/bin/bash
echo `whoami`
cd /home/git/labhub
echo `pwd`
# test command
#bundle exec rake gitlab:env:info RAILS_ENV=production

#TODO: backup
#bundle exec rake gitlab:backup:create

# get source code
git pull --rebase
git submodule update

echo "-----------------------------git finish-------------------------------------------------"
#
bundle install --deployment
bundle exec rake assets:clean RAILS_ENV=production
bundle exec rake assets:precompile RAILS_ENV=production

echo "-------------------------bundle install finish------------------------------------------"
#setup DB
#TODO: clean current DB and setup an empty. 
#bundle exec rake gitlab:setup RAILS_ENV=production
#bundle exec rake db:migrate RAILS_ENV=production

echo "--------------------------migrate finish------------------------------------------------"
# run unit test
#bundle exec rake spec

echo "--------------------------spec finish---------------------------------------------------"
#scp /home/git/labhub/log/unittest_result.html 
# restart service
#service gitlab stop
#sleep 10
#service gitlab start
#check status
